import {LOGIN} from '@/services/api'
import {request, METHOD, removeAuthorization} from '@/utils/request'

/**
 * 登录服务
 * @param username 账户名
 * @param password 账户密码
 * @returns Promise<AxiosResponse>
 */
export async function login(username, password) {
    return request(LOGIN.USER, METHOD.POST, {
        username: username,
        password: password
    })
}

/**
 *
 * @returns Promise<AxiosResponse>
 */
export async function routes() {
    return request(LOGIN.ROUTES, METHOD.GET, {})
}

/**
 * 退出登录
 */
export function logout() {
    localStorage.removeItem(process.env.VUE_APP_ROUTES_KEY)
    localStorage.removeItem(process.env.VUE_APP_PERMISSIONS_KEY)
    localStorage.removeItem(process.env.VUE_APP_ROLES_KEY)
    removeAuthorization()
}
